﻿package com.bizmlib.utils
{
	
	public function getPolarCoordinates(x:Number, y:Number):Object
	{
		var r:Number = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
		var thau:Number = 0;
		
		/**
		if(x>=0 && r>0)
		{
			thau = Math.asin(y / r);
		}
		else if(r>0)
		{
			thau = - Math.asin(y / r) + Math.PI;
		}
		/**/
		thau = Math.PI/2 - Math.atan2(x, y);
		/**
		if(x > 0)
			thau = Math.atan(y / x);
		else if((x < 0) && (y >= 0))
			thau = Math.atan(y / x) + Math.PI;
		else if((x < 0) && (y < 0))
			thau = Math.atan(y / x) - Math.PI;
		else if((x==0) && (y > 0))
			thau = Math.PI / 2;
		else if((x==0) && (y < 0))
			thau = - Math.PI / 2;
		//else if((x==0) && (y==0))
		//	thau = 0;
		/**/
		
		return {r:r, t:thau};
	}
}